package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.utils.Timer;
	
	import org.osmf.events.TimeEvent;
	
	public class TitleBar extends Sprite
	{
		private		var	_textField:TextField = null;
		
		private		var	_isStop:Boolean = true;
		
		public function TitleBar(title:String)
		{
			super();
			
			var bitmap:BitmapData = new BitmapData(260, 20, true, 0x00ffffff);
			var bg:Bitmap = new Bitmap(bitmap);
			this.addChild(bg);
			
			this._textField = new TextField();
			this._textField.text = title;
			this.addChild(this._textField);
			this._textField.autoSize = TextFieldAutoSize.LEFT;
			this._textField.height = 20;
			this._textField.cacheAsBitmap = true;
			this._textField.textColor = 0x99ffffff;
			this.scrollRect = new Rectangle(0, 0, 260, 20);
			this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
			
		}
		
		public	function	onEnterFrame(evt:Event):void{
			
			if (this._isStop == true)
				return;
			
			this._textField.x += 2;
			
			if (this._textField.x > this.width)
				this._textField.x = -this._textField.textWidth;
		}
		
		
		public	function	set stop(isStop:Boolean):void{
			this._isStop = isStop;
		}
		
		
		public	function	setTitle(title:String):void{
			this._textField.text = title;
		}
	}
}